<?php

/**
 * @author @author Samrat Khan & Sadik Sarfaraz - Apr 13, 2013
 */
/**
 * 
 * @param string $db Common database connection string parameter
 * @return string $CI returns measurement from uom table
 */
function getUOM($db) {
    $query = "SELECT uom_id, measurement FROM uom";
        try {
            $stmt = $db->prepare($query);
            $stmt->execute();
        } catch (PDOException $ex) {
            die("Failed to run query: " . $ex->getMessage());
        }
        $rows = $stmt->fetchAll();

        foreach($rows as $row1) {
            $CI.="<option value='{$row1["uom_id"]}'>";
                $CI.=$row1['measurement'];
            $CI.="</option>";
            $CI++;
        }
        return $CI;
}
/**
 * 
 * @param numeric $id for selecting uom from the uom table
 * @param string $db Common database connection string parameter
 */
function uomBeauty($id, $db) {
    if($id == 1) {
        echo getName('uom', 'measurement', 'uom_id', $id, $db);
    } elseif($id == 2) {
        echo getName('uom', 'measurement', 'uom_id', $id, $db);
    } elseif($id == 3) {
        echo getName('uom', 'measurement', 'uom_id', $id, $db);
    } elseif($id == 4) {
        echo getName('uom', 'measurement', 'uom_id', $id, $db);
    }
}
?>